﻿using AngleSharp.Io;
using AngleSharp;
using HtmlAgilityPack;
using Lunar;
using Lunar.EightChar;
using Masuit.Tools;
using Newtonsoft.Json;
using SqlSugar;
using System.DirectoryServices;
using System.Globalization;
using System.Reflection;
using System.ServiceModel.Syndication;
using System.Text;
using System.Xml;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Text.Json;
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json.Linq;
using System.Net;
using HttpMethod = System.Net.Http.HttpMethod;
using MailKit.Net.Imap;
using MailKit;
using System.Security.Cryptography;

namespace ztDataNet.db
{
    public class utils
    {


        private static readonly HttpClient client = new HttpClient();
        private readonly ISqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
        {
            ConnectionString = "Server=119.45.240.39;Port=3306;Database=ztdata;Uid=ztData;Pwd=bPXREBwmFcMLA3sG;", // 这里填写你的数据库连接字符串
            DbType = DbType.MySql, // 设置数据库类型
            IsAutoCloseConnection = true, // 自动释放数据务，如果存在事务，在事务结束后释放
            InitKeyType = InitKeyType.Attribute // 从实体特性中读取主键自增列信息
        });
        public utils()
        {

        }

        public async Task<string> FetchAndPostRssItems()
        {
            var rssItems = new List<RssItem>();
            //  var url = "https://www.zhihu.com/rss";
            var url = "https://top.baidu.com/board?tab=realtime";
            //using (var reader = XmlReader.Create(url))
            //{
            //    var feed = SyndicationFeed.Load(reader);
            //    foreach (var item in feed.Items)
            //    {
            //        rssItems.Add(new RssItem
            //        {
            //            Title = item.Title.Text,
            //            Link = item.Links.First().Uri.ToString()
            //        });
            //    }
            //}


            var response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();
                var htmlDocument = new HtmlDocument();
                htmlDocument.LoadHtml(content);

                // 使用HtmlAgilityPack解析HTML内容
                // 例如，获取所有的h1标签
                var elements = htmlDocument.DocumentNode.SelectNodes("//*[contains(@class, 'category-wrap_iQLoo') and contains(@class, 'horizontal_1eKyQ')]");

                var parentElements = htmlDocument.DocumentNode.SelectNodes("//*[contains(@class, 'category-wrap_iQLoo') and contains(@class, 'horizontal_1eKyQ')]");

                if (parentElements != null)
                {
                    foreach (var parentElement in parentElements)
                    {
                        var textElements = parentElement.SelectNodes(".//*[contains(@class, 'c-single-text-ellipsis')]");
                        var hrefElements = parentElement.SelectNodes(".//*[contains(@class, 'title_dIF3B')]");

                        if (textElements != null && hrefElements != null)
                        {
                            for (int i = 0; i < textElements.Count && i < hrefElements.Count; i++)
                            {
                                var rssItem = new RssItem
                                {
                                    Title = textElements[i].InnerText.Trim(),
                                    Link = hrefElements[i].GetAttributeValue("href", string.Empty)
                                };

                                rssItems.Add(rssItem);
                            }
                        }
                    }
                }
                else
                {
                    return "";
                }
                var markdown = ConvertToMarkdown(rssItems,"UID_hJR4jmREqNwZseTPYkmWL1SEJcXO");
                var res = await PostMarkdownToUrl(markdown,"UID_hJR4jmREqNwZseTPYkmWL1SEJcXO");

                var markdown2 = ConvertToMarkdown(rssItems, "UID_72wvxyJ6QIjEn2LmAavHiGizh93E");
                var res2 = await PostMarkdownToUrl(markdown2, "UID_72wvxyJ6QIjEn2LmAavHiGizh93E");

                var markdown3 = ConvertToMarkdown(rssItems, "UID_85gTEA1g5XqVFOPyArS6PuvzHARf");
                var res3 = await PostMarkdownToUrl(markdown3, "UID_85gTEA1g5XqVFOPyArS6PuvzHARf");

                if (response.IsSuccessStatusCode)
                {
                    return res.IsSuccessStatusCode+"#"+res2.IsSuccessStatusCode+"#"+res3.IsSuccessStatusCode;
                }
                else
                {
                    throw new Exception($"Failed to post markdown to the specified URL. Status code: {response.StatusCode}");
                }
            }
            else
            {
                return "";
            }
        }
        public string ConvertToMarkdown(IEnumerable<RssItem> items,string uid)
        {
            //var sb = new StringBuilder();
            //foreach (var item in items)
            //{
            //    sb.AppendLine($"> ###### [{item.Title}]({item.Link})");
            //    //sb.AppendLine($"[连接跳转]({item.Link})");
            //    sb.AppendLine("---");
            //}
            var sb = new StringBuilder();
            var dd = new utils().LunarDate();
            sb.Append(dd.html);
            var d = new List<Td>();
            if (uid == "UID_72wvxyJ6QIjEn2LmAavHiGizh93E")
            {
                d = db.Queryable<Td>().Where(p => p.id==5).ToList();
                sb.Append("<table  style='border: 1px solid black; border-collapse: collapse;width:90vw;text-align:center'>");

                foreach (var item in d)
                {
                    sb.Append("<tr>");
                    
                    sb.Append($"<td  style='border: 1px solid black;' colspan='4'>{item.cname}</td>");
                    sb.Append("</tr>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>教派：</td><td  style='border: 1px solid black;width:25%'>{item.jp}</td>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>功法：</td><td  style='border: 1px solid black;width:25%'>{item.gf}</td>");
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>修为：</td><td  style='border: 1px solid black;width:25%'>{item.xw}</td>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>心境：</td><td  style='border: 1px solid black;width:25%'>{item.xj}</td>");
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>元神：</td><td  style='border: 1px solid black;width:25%'>{item.ys}%</td>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>综合：</td><td  style='border: 1px solid black;width:25%'>{item.zh}%</td>");
                
                    // 添加其他字段...
                    sb.Append("</tr>");
                }

                sb.Append("</table>");
            }
            else if (uid == "UID_85gTEA1g5XqVFOPyArS6PuvzHARf")
            {
                d = db.Queryable<Td>().Where(p => p.id==6).ToList();
                sb.Append("<table  style='border: 1px solid black; border-collapse: collapse;width:90vw;text-align:center'>");

                foreach (var item in d)
                {
                    sb.Append("<tr>");

                    sb.Append($"<td  style='border: 1px solid black;' colspan='4'>{item.cname}</td>");
                    sb.Append("</tr>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>教派：</td><td  style='border: 1px solid black;width:25%'>{item.jp}</td>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>功法：</td><td  style='border: 1px solid black;width:25%'>{item.gf}</td>");
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>修为：</td><td  style='border: 1px solid black;width:25%'>{item.xw}</td>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>心境：</td><td  style='border: 1px solid black;width:25%'>{item.xj}</td>");
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>元神：</td><td  style='border: 1px solid black;width:25%'>{item.ys}%</td>");
                    sb.Append($"<td  style='border: 1px solid black;width:25%'>综合：</td><td  style='border: 1px solid black;width:25%'>{item.zh}%</td>");

                    // 添加其他字段...
                    sb.Append("</tr>");
                }

                sb.Append("</table>");
            }
            //return sb.ToString();
            
            var cdt = Lunar.Lunar.FromDate(DateTime.Now);

            //https://6tail.cn/calendar/api.html#lunar.tianshen.html
            sb.AppendLine("<table style='border: 1px solid black; border-collapse: collapse;width:90vw'>");
            //sb.AppendLine("<tr><th style='border: 1px solid black;'>"+Solar.FromDate(DateTime.Now).YmdHms+"</th></tr>");
            //sb.AppendLine("<tr><th style='border: 1px solid black;'>"+cdt+"</th></tr>");
            //sb.AppendLine("<tr><th style='border: 1px solid black;'>"+cdt.YearInGanZhi+cdt.MonthInGanZhi+cdt.DayInGanZhi+"</th></tr>");
            sb.AppendLine("<tr><th style='border: 1px solid black;'>↓↓↓离珠今日热搜榜↓↓↓</th></tr>");
            foreach (var item in items)
            {
                sb.AppendLine("<tr>");
                //sb.AppendFormat("<td>{0}</td>", item.Text);
                sb.AppendFormat("<td style='height:4vh;border: 1px solid black;'><a href='{0}' style='margin-left:4vw;'>"+item.Title+"</a></td>", item.Link);
                sb.AppendLine("</tr>");
            }

            sb.AppendLine("</table>");
           
            return sb.ToString();
        }
        public DateInfo LunarDate()
        {
            DateTime now = DateTime.Now;
            Lunar.Lunar d = Lunar.Lunar.FromDate(now);
           

            var year = LunarYear.FromYear(d.Year);

            var month = year.GetMonth(d.Month);

            Yun man = d.EightChar.GetYun(1);
            Yun woman = d.EightChar.GetYun(0);
            List<string> dy = new List<string>();
            List<string> ln = new List<string>();
            // 获取大运表
            DaYun[] daYunArr = man.GetDaYun();
            for (int i = 0, j = daYunArr.Length; i<j; i++)
            {
                DaYun daYun = daYunArr[i];
                dy.Add("男大运[" + i + "] = " + daYun.StartYear + "年 " + daYun.StartAge + "岁 " + daYun.GanZhi);
            }
            DaYun[] daYunArr2 = woman.GetDaYun();
            for (int i = 0, j = daYunArr2.Length; i<j; i++)
            {
                DaYun daYun = daYunArr2[i];
                dy.Add("女大运[" + i + "] = " + daYun.StartYear + "年 " + daYun.StartAge + "岁 " + daYun.GanZhi);
            }
            // 第1次大运流年
            LiuNian[] LiuNianArr = daYunArr[1].GetLiuNian();
            for (int i = 0, j = LiuNianArr.Length; i<j; i++)
            {
                LiuNian liuNian = LiuNianArr[i];
                ln.Add("男流年[" + i + "] = " + liuNian.Year + "年 " + liuNian.Age + "岁 " + liuNian.GanZhi);
            }
            LiuNian[] LiuNianArr2 = daYunArr2[1].GetLiuNian();
            for (int i = 0, j = LiuNianArr2.Length; i<j; i++)
            {
                LiuNian liuNian = LiuNianArr2[i];
                ln.Add("女流年[" + i + "] = " + liuNian.Year + "年 " + liuNian.Age + "岁 " + liuNian.GanZhi);
            }
            var info = new DateInfo
            {
                Date = now.ToString("yyyy年MM月dd日"),
                LunarDate = d.ToString(),
                TimeInGanZhi = d.TimeInGanZhi,
                Week = "星期"+d.WeekInChinese,
                Festivals = d.Festivals,
                OtherFestivals = d.OtherFestivals,
                GanZhi=d.YearInGanZhi+"-"+d.MonthInGanZhi+"-"+d.DayInGanZhi+"-"+d.TimeInGanZhi,
                Lu=d.DayLu,
                ShengXiao=d.YearShengXiaoExact+"-"+d.MonthShengXiao+"-"+d.DayShengXiao+"-"+d.TimeShengXiao,
                JieQi=d.JieQi,
                WuHou=d.WuHou+"-"+d.Hou,
                ShuJiu=d.ShuJiu==null ? "" : d.ShuJiu.Name+"-"+d.ShuJiu.Index,
                Fu = d.Fu==null ? "" : d.Fu.Name+"-"+d.Fu.Index,
                LiuYao = d.LiuYao,
                QiZheng = d.Zheng,
                Xiu = new List<string>() { d.Xiu, d.Animal,d.XiuLuck, d.XiuSong },
                SiGong=d.Gong,
                SiShen=d.Shou,
                PengZu=d.PengZuGan+","+d.PengZuZhi,
                FangWei=new List<string>() {
                    "喜神方位:"+d.DayPositionXi+"="+d.DayPositionXiDesc,
                    "阳贵神方位:"+d.DayPositionYangGui+"="+d.DayPositionYangGuiDesc,
                    "阴贵神方位:"+d.DayPositionYinGui+"="+d.DayPositionYinGuiDesc,
                    "福神方位:"+d.DayPositionFu+"="+d.DayPositionFuDesc,
                    "财神方位:"+d.DayPositionCai+"="+d.DayPositionCaiDesc,
                    "今日胎神:"+d.DayPositionTai,
                    "本月胎神:"+d.MonthPositionTai,
                    "年太岁方位:"+year.PositionTaiSui+"="+year.PositionTaiSuiDesc,
                    "月太岁方位:"+month.PositionTaiSui+"="+month.PositionTaiSuiDesc,
                    "日太岁方位:"+d.DayPositionTaiSui+"="+d.DayPositionTaiSuiDesc,
                },
                ChongSha=new List<string>()
                {
                    "日冲:"+d.DayChongDesc,
                    "日煞:"+d.DaySha,
                    "时冲:"+d.TimeChongDesc,
                    "时煞:"+d.TimeSha,
                },
                NaYin=d.YearNaYin+"-"+d.MonthNaYin+"-"+d.DayNaYin+"-"+d.TimeNaYin,
                BaZi=new List<string>()
                {
                    d.TimeInGanZhi,
                    d.EightChar.YearWuXing + ", " + d.EightChar.MonthWuXing + ", " + d.EightChar.DayWuXing + ", " + d.EightChar.TimeWuXing,
                    d.YearNaYin + ", " + d.MonthNaYin + ", " + d.DayNaYin + ", " + d.TimeNaYin,
                    "年支十神:" + string.Join(",", d.EightChar.YearShiShenZhi),
                    "月支十神:" + string.Join(",", d.EightChar.MonthShiShenZhi),
                    "日支十神:" + string.Join(",", d.EightChar.DayShiShenZhi),
                    "时支十神:" + string.Join(",", d.EightChar.TimeShiShenZhi),
                    "男运:出生" + man.StartYear + "年" + man.StartMonth + "个月" + man.StartDay + "天后起运",
                    "女运:出生" + woman.StartYear + "年" + woman.StartMonth + "个月" + woman.StartDay + "天后起运"
                },
                DaYun=dy,
                LiuNian=ln,
                XunKong=new List<string>() {
                    "年:" + d.YearXunKong,
                    "月:" + d.MonthXunKong,
                    "日:" + d.DayXunKong,

                },
                ZhiXing=d.ZhiXing,
                TianShen=new List<string>() {
                    "天:"+d.DayTianShen+"-"+d.DayTianShenType+"-"+d.DayTianShenLuck,
                    "时:"+d.TimeTianShen+"-"+d.TimeTianShenType+"-"+d.TimeTianShenLuck
                },
                YJ = new List<List<string>>()
                {
                    d.DayYi,
                    d.DayJi,
                    d.TimeYi,
                    d.TimeJi
                },
                JiShenXiongSha= new List<List<string>>()
                {
                    d.DayJiShen,
                    d.DayXiongSha
                },
                YueXiang=d.YueXiang,
                JiuXing=new List<string>()
                {
                    d.YearNineStar.FullString,
                    d.MonthNineStar.FullString,
                    d.DayNineStar.FullString,
                    d.TimeNineStar.FullString,
                },
                Fo=d.Foto.FullString,
                Dao=d.Tao.FullString
            };
            info.html = ConvertToHtml(info);

            return info;
        }
        public DateInfo LunarDate(DateTime now)
        {
            
            Lunar.Lunar d = Lunar.Lunar.FromDate(now);


            var year = LunarYear.FromYear(d.Year);

            var month = year.GetMonth(d.Month);

            Yun man = d.EightChar.GetYun(1);
            Yun woman = d.EightChar.GetYun(0);
            List<string> dy = new List<string>();
            List<string> ln = new List<string>();
            // 获取大运表
            DaYun[] daYunArr = man.GetDaYun();
            for (int i = 0, j = daYunArr.Length; i<j; i++)
            {
                DaYun daYun = daYunArr[i];
                dy.Add("男大运[" + i + "] = " + daYun.StartYear + "年 " + daYun.StartAge + "岁 " + daYun.GanZhi);
            }
            DaYun[] daYunArr2 = woman.GetDaYun();
            for (int i = 0, j = daYunArr2.Length; i<j; i++)
            {
                DaYun daYun = daYunArr2[i];
                dy.Add("女大运[" + i + "] = " + daYun.StartYear + "年 " + daYun.StartAge + "岁 " + daYun.GanZhi);
            }
            // 第1次大运流年
            LiuNian[] LiuNianArr = daYunArr[1].GetLiuNian();
            for (int i = 0, j = LiuNianArr.Length; i<j; i++)
            {
                LiuNian liuNian = LiuNianArr[i];
                ln.Add("男流年[" + i + "] = " + liuNian.Year + "年 " + liuNian.Age + "岁 " + liuNian.GanZhi);
            }
            LiuNian[] LiuNianArr2 = daYunArr2[1].GetLiuNian();
            for (int i = 0, j = LiuNianArr2.Length; i<j; i++)
            {
                LiuNian liuNian = LiuNianArr2[i];
                ln.Add("女流年[" + i + "] = " + liuNian.Year + "年 " + liuNian.Age + "岁 " + liuNian.GanZhi);
            }
            var info = new DateInfo
            {
                Date = now.ToString("yyyy年MM月dd日"),
                LunarDate = d.ToString(),
                TimeInGanZhi = d.TimeInGanZhi,
                Week = "星期"+d.WeekInChinese,
                Festivals = d.Festivals,
                OtherFestivals = d.OtherFestivals,
                GanZhi=d.YearInGanZhi+"-"+d.MonthInGanZhi+"-"+d.DayInGanZhi+"-"+d.TimeInGanZhi,
                Lu=d.DayLu,
                ShengXiao=d.YearShengXiaoExact+"-"+d.MonthShengXiao+"-"+d.DayShengXiao+"-"+d.TimeShengXiao,
                JieQi=d.JieQi,
                WuHou=d.WuHou+"-"+d.Hou,
                ShuJiu=d.ShuJiu==null ? "" : d.ShuJiu.Name+"-"+d.ShuJiu.Index,
                Fu = d.Fu==null ? "" : d.Fu.Name+"-"+d.Fu.Index,
                LiuYao = d.LiuYao,
                QiZheng = d.Zheng,
                Xiu = new List<string>() { d.Xiu, d.Animal, d.XiuLuck, d.XiuSong },
                SiGong=d.Gong,
                SiShen=d.Shou,
                PengZu=d.PengZuGan+","+d.PengZuZhi,
                FangWei=new List<string>() {
                    "喜神方位:"+d.DayPositionXi+"="+d.DayPositionXiDesc,
                    "阳贵神方位:"+d.DayPositionYangGui+"="+d.DayPositionYangGuiDesc,
                    "阴贵神方位:"+d.DayPositionYinGui+"="+d.DayPositionYinGuiDesc,
                    "福神方位:"+d.DayPositionFu+"="+d.DayPositionFuDesc,
                    "财神方位:"+d.DayPositionCai+"="+d.DayPositionCaiDesc,
                    "今日胎神:"+d.DayPositionTai,
                    "本月胎神:"+d.MonthPositionTai,
                    "年太岁方位:"+year.PositionTaiSui+"="+year.PositionTaiSuiDesc,
                    "月太岁方位:"+month.PositionTaiSui+"="+month.PositionTaiSuiDesc,
                    "日太岁方位:"+d.DayPositionTaiSui+"="+d.DayPositionTaiSuiDesc,
                },
                ChongSha=new List<string>()
                {
                    "日冲:"+d.DayChongDesc,
                    "日煞:"+d.DaySha,
                    "时冲:"+d.TimeChongDesc,
                    "时煞:"+d.TimeSha,
                },
                NaYin=d.YearNaYin+"-"+d.MonthNaYin+"-"+d.DayNaYin+"-"+d.TimeNaYin,
                BaZi=new List<string>()
                {
                    d.TimeInGanZhi,
                    d.EightChar.YearWuXing + ", " + d.EightChar.MonthWuXing + ", " + d.EightChar.DayWuXing + ", " + d.EightChar.TimeWuXing,
                    d.YearNaYin + ", " + d.MonthNaYin + ", " + d.DayNaYin + ", " + d.TimeNaYin,
                    "年支十神:" + string.Join(",", d.EightChar.YearShiShenZhi),
                    "月支十神:" + string.Join(",", d.EightChar.MonthShiShenZhi),
                    "日支十神:" + string.Join(",", d.EightChar.DayShiShenZhi),
                    "时支十神:" + string.Join(",", d.EightChar.TimeShiShenZhi),
                    "男运:出生" + man.StartYear + "年" + man.StartMonth + "个月" + man.StartDay + "天后起运",
                    "女运:出生" + woman.StartYear + "年" + woman.StartMonth + "个月" + woman.StartDay + "天后起运"
                },
                DaYun=dy,
                LiuNian=ln,
                XunKong=new List<string>() {
                    "年:" + d.YearXunKong,
                    "月:" + d.MonthXunKong,
                    "日:" + d.DayXunKong,

                },
                ZhiXing=d.ZhiXing,
                TianShen=new List<string>() {
                    "天:"+d.DayTianShen+"-"+d.DayTianShenType+"-"+d.DayTianShenLuck,
                    "时:"+d.TimeTianShen+"-"+d.TimeTianShenType+"-"+d.TimeTianShenLuck
                },
                YJ = new List<List<string>>()
                {
                    d.DayYi,
                    d.DayJi,
                    d.TimeYi,
                    d.TimeJi
                },
                JiShenXiongSha= new List<List<string>>()
                {
                    d.DayJiShen,
                    d.DayXiongSha
                },
                YueXiang=d.YueXiang,
                JiuXing=new List<string>()
                {
                    d.YearNineStar.FullString,
                    d.MonthNineStar.FullString,
                    d.DayNineStar.FullString,
                    d.TimeNineStar.FullString,
                },
                Fo=d.Foto.FullString,
                Dao=d.Tao.FullString
            };
            info.html = ConvertToHtml(info);

            return info;
        }
        public async Task<HttpResponseMessage> PostMarkdownToUrl(string markdown, string uid)
        {
            var postUrl = "https://wxpusher.zjiecode.com/api/send/message";
            var postData = new
            {
                appId = 66962,
                appToken = "AT_4N6n8mIUdgupqxIjQfAkLO78jwmZNiv0",
                content = markdown,
                contentType = 2,
                uids = new List<string> { uid },
                verifyPay = false
            };
            var content = new StringContent(JsonConvert.SerializeObject(postData), Encoding.UTF8, "application/json");
            return await client.PostAsync(postUrl, content);
        }


        public static string ConvertToHtml(DateInfo d)
        {
            var html = new StringBuilder("");
            html.Append($"<div style='box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);transition: 0.3s;width: 94vw;border-radius: 5px;background-color: #f2f2f2;padding: 20px;' class=\"card w-92 bg-neutral text-neutral-content\">");
            html.Append($"<div class=\"card-body  text-center\">");
            html.Append($"<h3 class=\"card-title\" style='color: #4CAF50;text-align: center;'><b>{d.Date}</b></h3>");
            html.Append($"<h5 style='text-align: center;color:#000'><b>{d.Week}</b></h5>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.LunarDate} {d.TimeInGanZhi}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.GanZhi}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: left;font-size: 0.8rem;border:1px #4CAF50 solid;padding:1vh;color:#4CAF50'><b>{string.Join(",", d.YJ[0])}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: left;font-size: 0.8rem;border:1px #FF5733 solid;padding:1vh;color:#FF5733'><b>{string.Join(",", d.YJ[1])}</b></p>");
            html.Append($"</div>");


            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.NaYin}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.PengZu}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>四方:<b>{d.SiGong}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>星宿:<b>{d.Xiu[0]+d.Xiu[1]+"-"+d.Xiu[2]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>四神:<b>{d.SiShen}</b></p>");

            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            
           
            string[] lines = d.Xiu[3].Split('，', '。'); // 根据逗号和句号分割
            var line = "";
            for (int i = 0; i < lines.Length; i+=2)
            {
                
                // 每两小句一行
                if (i + 1 < lines.Length)
                {
                    line+=lines[i] + "，" + lines[i + 1] + "。<br>";
                }
                else
                {
                    // 如果是最后一行且小句数是奇数，单独一行
                    //line+=lines[i] + "。<br>";
                }
            }
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{line}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>七政:<b>{d.QiZheng}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>月相:<b>{d.YueXiang}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>值星:<b>{d.ZhiXing}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>禄:<b>{d.Lu}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.ShengXiao}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>六耀:<b>{d.LiuYao}</b></p>");
            html.Append($"</div>");

         
          
         
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>喜神方位<br><b>{d.FangWei[0].Split(':')[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>福神方位<br><b>{d.FangWei[3].Split(':')[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>财神方位<br><b>{d.FangWei[4].Split(':')[1]}</b></p>");
            html.Append($"</div>");
          
          
          
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>阳贵神<br><b>{d.FangWei[2].Split(':')[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'><b>日胎:{d.FangWei[5].Split(':')[1]}<br>月胎:{d.FangWei[6].Split(':')[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>阴贵神<br><b>{d.FangWei[3].Split(':')[1]}</b></p>");
            html.Append($"</div>");
           
         
          
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>年太岁<br><b>{d.FangWei[7].Split(':')[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>月太岁<br><b>{d.FangWei[8].Split(':')[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;border:1px #4CAF50 solid;margin: 0'>日太岁<br><b>{d.FangWei[9].Split(':')[1]}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>天神:<b>{d.TianShen[0]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>时神:<b>{d.TianShen[1]}</b></p>");

            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>旬空:<b>{d.XunKong[0]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>旬空:<b>{d.XunKong[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>旬空:<b>{d.XunKong[2]}</b></p>");
           
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.ChongSha[0]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.ChongSha[1]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.ChongSha[2]}</b></p>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.ChongSha[3]}</b></p>");
            html.Append($"</div>");
           
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>吉星:<b>{string.Join(",", d.JiShenXiongSha[0])}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>凶煞:<b>{string.Join(",", d.JiShenXiongSha[1])}</b></p>");
            html.Append($"</div>");

            foreach (var j in d.JiuXing)
            {
                html.Append($"<div style='display: flex;justify-content: space-between;'>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>九星:<b>{j}</b></p>");
                html.Append($"</div>");
            }
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>佛歷{d.Fo}</b></p>");
            html.Append($"</div>");
            html.Append($"<div style='display: flex;justify-content: space-between;'>");
            html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'><b>{d.Dao}</b></p>");
            
            html.Append($"</div>");
            if (d.Festivals.Count>0 || d.OtherFestivals.Count>0)
            {
                html.Append($"<div style='display: flex;justify-content: space-between;'>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>节日</p>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>其他节日</p>");
                html.Append($"</div>");
              
            }
            if (!string.IsNullOrEmpty(d.ShuJiu) || !string.IsNullOrEmpty(d.Fu))
            {
                html.Append($"<div style='display: flex;justify-content: space-between;'>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>数九:{d.ShuJiu}</p>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>三伏:{d.Fu}</p>");
                html.Append($"</div>");
            }
            if (!string.IsNullOrEmpty(d.JieQi) || !string.IsNullOrEmpty(d.WuHou))
            {
                html.Append($"<div style='display: flex;justify-content: space-between;'>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>节气:{d.JieQi}</p>");
                html.Append($"<p style='color: #000;flex: 1;text-align: center;font-size: 0.8rem;'>{d.WuHou}</p>");
                html.Append($"</div>");
            }
            html.Append($"</div>");
            html.Append($"</div>");
            //foreach (var property in typeof(DateInfo).GetProperties())
            //{
            //if (property.Name != "html")
                //{
                    //var value = property.GetValue(dateInfo);
                    //var attribute = (ChineseNameAttribute)property.GetCustomAttribute(typeof(ChineseNameAttribute));
                    //var chineseName = attribute != null ? attribute.Name : property.Name;
                    //if (value is List<string> list)
                    //{
                    //    html.Append($"<h2>{chineseName}</h2>");
                    //    html.Append("<ul>");
                    //    foreach (var item in list)
                    //    {
                    //        html.Append($"<li>{item}</li>");
                    //    }
                    //    html.Append("</ul>");
                    //}
                    //else if (value is List<List<string>> nestedList)
                    //{
                    //    html.Append($"<h2>{chineseName}</h2>");
                    //    foreach (var sublist in nestedList)
                    //    {
                    //        html.Append("<ul>");
                    //        foreach (var item in sublist)
                    //        {
                    //            html.Append($"<li>{item}</li>");
                    //        }
                    //        html.Append("</ul>");
                    //    }
                    //}
                    //else
                    //{
                    //    html.Append($"<h2>{chineseName}</h2><p>{value}</p>");
                    //}
                    
               // }

            //}

            return html.ToString();

        }
        public static async Task<string> GetSession(string js_code)
        {
            var url = "https://api.weixin.qq.com/sns/jscode2session";
            var AppId = "wx437cc170f9185234";
            var AppSecret = "88f80409863285f853d5ac1724d77fb2aaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            var grant_type = "authorization_code";

            var requestData = new
            {
                AppId,
                AppSecret = AppSecret.Substring(0, 32),
                js_code,
                grant_type
            };

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.PostAsJsonAsync(url, requestData);
                response.EnsureSuccessStatusCode();

                var responseBody = await response.Content.ReadAsStringAsync();

                // 可以根据需要对响应内容进行处理
                // ...

                return responseBody;
            }
        }

        public static async Task<string> getToken()
        {
           
            var AppId = "wx437cc170f9185234";
            var AppSecret = "88f80409863285f853d5ac1724d77fb2";
            var grant_type = "client_credential";

            var url = "https://api.weixin.qq.com/cgi-bin/token?appid="+AppId+"&secret="+AppSecret+"&grant_type="+grant_type;

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(url);
                //response.EnsureSuccessStatusCode();

                var responseBody = await response.Content.ReadAsStringAsync();

                // 可以根据需要对响应内容进行处理
                // ...
                try
                {
                    var responseObject = JsonConvert.DeserializeObject<ResponseObject>(responseBody);

                    // 输出转换后的对象的属性值
                    Console.WriteLine("Access Token: " + responseObject.access_token);
                    Console.WriteLine("Expires In: " + responseObject.expires_in);

                    return responseObject.access_token;
                }
                catch (Newtonsoft.Json.JsonException ex)
                {
                    Console.WriteLine("JSON 解析错误：" + ex.Message);
                    return ex.Message;
                }
               
            }
        }
        public static async Task<string> jscode2session(string AppId,string AppSecret,string code,string encryptedData, string encryptIv)
        {

            
            var grant_type = "authorization_code";

            var url = "https://api.weixin.qq.com/sns/jscode2session?appid="+AppId+"&secret="+AppSecret+"&js_code="+code+"&grant_type="+grant_type;

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(url);
                //response.EnsureSuccessStatusCode();

                var responseBody = await response.Content.ReadAsStringAsync();

                // 可以根据需要对响应内容进行处理
                // ...
                try
                {
                    var responseObject = JsonConvert.DeserializeObject<ResponseObject2>(responseBody);

                    // 输出转换后的对象的属性值

                    //responseObject.openid
                    string r = WechatDecrypt(encryptedData, encryptIv, responseObject.session_key);
                    return r;
                }
                catch (Newtonsoft.Json.JsonException ex)
                {
                    Console.WriteLine("JSON 解析错误：" + ex.Message);
                    return ex.Message;
                }

            }
        }
        /// <summary>
        /// 解密微信数据
        /// </summary>
        /// <param name="encryptedData">加密的数据</param>
        /// <param name="encryptIv">iv向量</param>
        /// <param name="sessionKey">调用 wx auth.code2Session 来获得</param>
        /// <returns></returns>
        public static string WechatDecrypt(string encryptedData, string encryptIv, string sessionKey)
        {
            //base64解码为字节数组
            var encryptData = Convert.FromBase64String(encryptedData);
            var key = Convert.FromBase64String(sessionKey);
            var iv = Convert.FromBase64String(encryptIv);

            //创建aes对象
            var aes = Aes.Create();

            if (aes == null)
            {
                throw new InvalidOperationException("未能获取Aes算法实例");
            }
            //设置模式为CBC
            aes.Mode = CipherMode.CBC;
            //设置Key大小
            aes.KeySize = 128;
            //设置填充
            aes.Padding = PaddingMode.PKCS7;
            aes.Key = key;
            aes.IV = iv;

            //创建解密器
            var de = aes.CreateDecryptor();
            //解密数据
            var decodeByteData = de.TransformFinalBlock(encryptData, 0, encryptData.Length);
            //转换为字符串
            var data = Encoding.UTF8.GetString(decodeByteData);

            return data;
        }

        #region 发送订阅消息===============================

        /// <summary>

        /// 发送订阅消息

        /// <param name="touser">用户openid</param>

        /// <param name="city">城市</param>

        /// <param name="location">地址</param>

        /// <param name="weather">天气</param>

        /// <returns>返回值{"errcode":0,"errmsg":"ok"}</returns>

        /// </summary>

        public static async Task<string> Send_Subscribe(string touser, string thing3, string thing10, string phrase5)

        {

            string access_token = await getToken();//Access_Token

            string _url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + access_token;

            string timenow = Convert.ToDateTime(DateTime.Now).ToString("yyyy年MM月dd日");

            //json参数

            string jsonParam = "{\"touser\": \"" + touser + "\",\"template_id\": \"WSjNDldNqeCMYHivK2bITtFJT-F68y-AiKfabqfrV4A\",\"page\": \"/subPages/pages/task/index?openid="+touser+"\",\"data\": {\"date2\": { \"value\": \"" + timenow + "\"},\"thing3\": {\"value\": \"" + thing3 + "\"},\"thing10\": {\"value\": \"" + thing10 + "\"},\"phrase5\": {\"value\": \"" + phrase5 + "\"}}}";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url);

            request.Method = "POST";

            request.Timeout = 5000;

            request.ContentType = "application/json;charset=UTF-8";

            byte[] byteData = Encoding.UTF8.GetBytes(jsonParam);

            int length = byteData.Length;

            request.ContentLength = length;

            using (Stream writer = request.GetRequestStream())

            {

                writer.Write(byteData, 0, length);

                writer.Close();

            }

            string jsonStrings = string.Empty;

            using (HttpWebResponse responses = (HttpWebResponse)request.GetResponse())

            {

                using (Stream streams = responses.GetResponseStream())

                {

                    using (StreamReader readers = new StreamReader(streams, System.Text.Encoding.UTF8))

                    {

                        jsonStrings = readers.ReadToEnd();

                        responses.Close();

                        streams.Close();

                        readers.Close();

                    }

                }

            }

            //{"errcode":0,"errmsg":"ok"}
            Serilog.Log.Information($"Send_Subscribe INFO: {jsonStrings}");
            JObject jo = (JObject)JsonConvert.DeserializeObject(jsonStrings);

            string errcode = jo["errcode"].ToString();

            string errmsg = jo["errmsg"].ToString();
            return errcode;
            //写日志

          //  LogUtils.Write(errcode + "," + errmsg);

        }

        #endregion
        public static async Task<string> GotoWatermark(string vurl)
        {
            //var url = "https://tenapi.cn/v2/video?url="+vurl;

            var url = "https://acid.jiuzige.com.cn/web/index/analysis?url="+vurl;


            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(url);
                
                var responseBody = await response.Content.ReadAsStringAsync();

                // 可以根据需要对响应内容进行处理
                // ...
                Serilog.Log.Information($"GotoWatermark INFO: {responseBody}");
                return responseBody;
            }
        }

        public static async Task<string> CallApiAsync(string url,  string data, string headers, string method)
        {
            Serilog.Log.Information($"CallApiAsync INFO: {url},{data},{headers},{method}");
            using var client = new HttpClient();
            HttpMethod httpMethod = new HttpMethod(method.ToUpper());
            using var request = new HttpRequestMessage(httpMethod, url);

            // 如果是POST或PUT，并且有数据，则添加到请求体
            if ((httpMethod == System.Net.Http.HttpMethod.Post || httpMethod == HttpMethod.Put) && !string.IsNullOrEmpty(data))
            {
                request.Content = new StringContent(data, Encoding.UTF8, "application/json");
            }

            // 解析headers字符串为键值对并添加到请求
            if (!string.IsNullOrEmpty(headers))
            {
                var headersPairs = headers.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var pair in headersPairs)
                {
                    var keyValue = pair.Split(new[] { ':' }, 2);
                    if (keyValue.Length == 2)
                    {
                        request.Headers.TryAddWithoutValidation(keyValue[0].Trim(), keyValue[1].Trim());
                    }
                }
            }

            // 发送请求并获取响应
            using var response = await client.SendAsync(request);
            return await response.Content.ReadAsStringAsync();
        }
        public async Task<List<Email>> FetchEmailsAsync(string host, int port, bool useSsl, string email, string password)
        {
            using (var client = new ImapClient())
            {
                await client.ConnectAsync(host, port, useSsl);
                await client.AuthenticateAsync(email, password);

                var inbox = client.Inbox;
                await inbox.OpenAsync(FolderAccess.ReadOnly);

                var emails = new List<Email>();
                for (var i = 0; i < inbox.Count; i++)
                {
                    var message = await inbox.GetMessageAsync(i);
                    emails.Add(new Email
                    {
                        From = message.From.Mailboxes.FirstOrDefault()?.Address,
                        Subject = message.Subject,
                        Body = message.TextBody,
                        Date = message.Date
                    });
                }

                await client.DisconnectAsync(true);
                return emails;
            }
        }
    }
/// <summary>
/// 邮件
/// </summary>
public class Email
{
    public string From { get; set; }
    public string Subject { get; set; }
    public string Body { get; set; }
    public DateTimeOffset Date { get; set; }
}
// 定义 Data 类来表示外层数据结构
public class Data
{
    public string touser { get; set; }
    public string template_id { get; set; }
    public string page { get; set; }
    public TemplateData data { get; set; }
}

// 定义 TemplateData 类来表示模板内容
public class TemplateData
{
    public TemplateItem date2 { get; set; }
    public TemplateItem thing3 { get; set; }
    public TemplateItem thing10 { get; set; }

    public TemplateItem phrase5 { get; set; }
}

// 定义 TemplateItem 类来表示模板中的各个属性
public class TemplateItem
{
    public string value { get; set; }
}
// 创建一个类来匹配 JSON 结构
public class ResponseObject
    {
        public string access_token { get; set; }
        public int expires_in { get; set; }
    }
    public class ResponseObject2
    {
        public string session_key { get; set; }
        public string unionid { get; set; }
        public string errmsg { get; set; }
        public string openid { get; set; }
        public int errcode { get; set; }
    }
    public class DateInfo
    {
        [ChineseName("公历时间")]
        public string Date { get; set; }
        [ChineseName("农历时间")]
        public string LunarDate { get; set; }
        [ChineseName("时辰")]
        public string TimeInGanZhi { get; set; }
        [ChineseName("星期")]
        public string Week { get; set; }
        [ChineseName("节日")]
        public List<string> Festivals { get; set; }
        [ChineseName("其他节日")]
        public List<string> OtherFestivals { get; set; }

        [ChineseName("干支")]
        public string GanZhi { get; set; }
        [ChineseName("禄")]
        public string Lu { get; set; }

        [ChineseName("生肖")]
        public string ShengXiao { get; set; }
        [ChineseName("节气")]
        public string JieQi { get; set; }
        [ChineseName("物候")]
        public string WuHou { get; set; }
        [ChineseName("数九")]
        public string ShuJiu { get; set; }
        [ChineseName("三伏")]
        public string Fu { get; set; }
        [ChineseName("六耀")]
        public string LiuYao { get; set; }
        [ChineseName("七政")]
        public string QiZheng { get; set; }
        [ChineseName("星宿")]
        public List<string> Xiu { get; set; }
        [ChineseName("四宫")]
        public string SiGong { get; set; }
        [ChineseName("四神")]
        public string SiShen { get; set; }
        [ChineseName("彭祖")]
        public string PengZu { get; set; }
        [ChineseName("方位")]
        public List<string> FangWei { get; set; }
        [ChineseName("冲煞")]
        public List<string> ChongSha { get; set; }
        [ChineseName("纳音")]
        public string NaYin { get; set; }
        [ChineseName("八字")]
        public List<string> BaZi { get; set; }
        [ChineseName("大运")]
        public List<string> DaYun { get; set; }
        [ChineseName("流年")]
        public List<string> LiuNian { get; set; }
        [ChineseName("寻空")]
        public List<string> XunKong { get; set; }
        [ChineseName("值星")]
        public string ZhiXing { get; set; }
        [ChineseName("天神")]
        public List<string> TianShen { get; set; }
        [ChineseName("宜忌")]
        public List<List<string>> YJ { get; set; }
        [ChineseName("吉神凶煞")]
        public List<List<string>> JiShenXiongSha { get; set; }
        [ChineseName("月相")]
        public string YueXiang { get; set; }
        [ChineseName("九星")]
        public List<string> JiuXing { get; set; }

        [ChineseName("佛历")]
        public string Fo { get; set; }
        [ChineseName("道历")]
        public string Dao { get; set; }

        public string html { get; set; }
    }
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class ChineseNameAttribute : Attribute
    {
        public string Name { get; private set; }

        public ChineseNameAttribute(string name)
        {
            Name = name;
        }
    }
}
